package com.faeple.statistics.dao.sqlmap;

import java.util.HashMap;
import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.faeple.statistics.dao.PostStatsDao;
import com.faeple.statistics.entity.LocationDto;

@Repository
public class SqlMapPostStatsDao implements PostStatsDao {

	@Autowired
	private SqlSession sqlSession;
	
	@Override
	public void addStats(HashMap<String, String> param) {
		sqlSession.insert("PostStatsMapper.addStats", param);
	}

	@Override
	public HashMap<String, Integer> getDashboardGenderStats(String idx) {
		return sqlSession.selectOne("PostStatsMapper.getDashboardGenderStats", idx);
	}

	@Override
	public HashMap<String, Integer> getDashboardAgeStats(String idx) {
		return sqlSession.selectOne("PostStatsMapper.getDashboardAgeStats", idx);
	}

	@Override
	public List<LocationDto> getDashboardLocationStats(String idx) {
		return sqlSession.selectList("PostStatsMapper.getDashboardLocationStats", idx);
	}

	@Override
	public HashMap<String, Integer> getDashboardViewcntStats(String idx) {
		return sqlSession.selectOne("PostStatsMapper.getDashboardViewcntStats", idx);
	}

	@Override
	public HashMap<String, Integer> getPostStats(HashMap<String, String> param) {
		return sqlSession.selectOne("PostStatsMapper.getPostStats", param);
	}

	@Override
	public List<LocationDto> getPostStatsLocation(String idx) {
		return sqlSession.selectList("PostStatsMapper.getPostStatsLocation", idx);
	}

	@Override
	public List<HashMap<String, String>> getPostList(String idx) {
		return sqlSession.selectList("PostStatsMapper.getPostList", idx);
	}

	@Override
	public int addBusinessViewCnt(HashMap<String, String> param) {
		return sqlSession.insert("PostStatsMapper.addBusinessViewCnt", param);
	}

	@Override
	public List<HashMap<String, Object>> getPostStatsWeekCnt(String idx) {
		return sqlSession.selectList("PostStatsMapper.getPostStatsWeekCnt", idx);
	}

	@Override
	public List<HashMap<String, String>> getPopularityPost(HashMap<String, String> param) {
		return sqlSession.selectList("PostStatsMapper.getPopularityPost", param);
	}

}
